var SysUserStateChangeDatagrid = new HgUi.Datagrid("SysUserStateChange_datagrid");
SysUserStateChangeDatagrid.toolbar = $("#SysUserStateChange_toolbar");
SysUserStateChangeDatagrid.options.isShowContextMenu = true;
SysUserStateChangeDatagrid.options.tipCells 
	= ["lockType","ip","originState","currentState","recordType","descr"];
SysUserStateChangeDatagrid.options.onSelect = function(index,row) {
    if (row && row.dictGroupId){
        SysUserStateChangeDatagrid.selectedRow = row;
    }
};
SysUserStateChangeDatagrid.options.onLoadSuccess = function(data) {
    SysUserStateChangeDatagrid.grid.datagrid("selectRow",0);
};
SysUserStateChangeDatagrid.init();
SysUserStateChangeDatagrid.bindDefaultToolbarEvent();


//状态类型combobox
SysUserStateChangeDatagrid.toolbar.find("#type").combobox({  
	panelHeight:'auto',
	editable:false,
	textField:'text',
	valueField:'value',    
	prompt: '---请选择---',
	data:HgUtil.getDictComboboxData('sysUserStateChangeType')
});
//原状态combobox
SysUserStateChangeDatagrid.toolbar.find("#originState").combobox({  
	panelHeight:'auto',
	editable:false,
	textField:'text',
	valueField:'value',    
	prompt: '---请选择---',
	data:HgUtil.getDictComboboxData('userStateType')
});
//现状态combobox
SysUserStateChangeDatagrid.toolbar.find("#currentState").combobox({  
	panelHeight:'auto',
	editable:false,
	textField:'text',
	valueField:'value',    
	prompt: '---请选择---',
	data:HgUtil.getDictComboboxData('userStateType')
});
//变更方式combobox
SysUserStateChangeDatagrid.toolbar.find("#crtType").combobox({  
	panelHeight:'auto',
	editable:false,
	textField:'text',
	valueField:'value',    
	prompt: '---请选择---',
	data:HgUtil.getDictComboboxData('crtTypeUserStateChange')
});
//是否当前状态combobox
SysUserStateChangeDatagrid.toolbar.find("#isCurrent").combobox({  
	panelHeight:'auto',
	editable:false,
	textField:'text',
	valueField:'value',    
	prompt: '---请选择---',
	data:HgUtil.getDictComboboxData('trueOrFalse')
});

//查询------------------------------------------------------------------------------------------------------
SysUserStateChangeDatagrid.toolbar.find("[tag=submit]").click(function(){
	var searchData = {};
	searchData["loginName"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=loginName]").val());
	searchData["type"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=type]").val());
	searchData["ipStr"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=ip]").val());
	searchData["originState"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=originState]").val());
	searchData["currentState"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=currentState]").val());
	
	searchData["crtType"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=crtType]").val());
	searchData["descr"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=descr]").val());
	searchData["isCurrent"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=isCurrent]").val());
	
	searchData["startTimeStr"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=startTime]").val());
	searchData["endTimeStr"] =  $.trim(SysUserStateChangeDatagrid.toolbar.find("[name=endTime]").val());
	if(searchData["startTimeStr"]){
		searchData["startTimeStr"] = searchData["startTimeStr"] + " 00:00:00";
	}
	if(searchData["endTimeStr"]){
		searchData["endTimeStr"] = searchData["endTimeStr"] + " 24:00:00";
	}
	
	SysUserStateChangeDatagrid.grid.datagrid('load',searchData);
});

// 清空查询---------------------------------------------------------------------------------------------------
SysUserStateChangeDatagrid.toolbar.find("[tag=clear]").click(function() {
    $("#SysUserLoginLogSearchForm").form("clear");
	//清空后combobox选中第一条“请选择”数据
    SysUserStateChangeDatagrid.toolbar.find("#type").combobox("setValue",'');
    SysUserStateChangeDatagrid.toolbar.find("#originState").combobox("setValue",''); 
    SysUserStateChangeDatagrid.toolbar.find("#currentState").combobox("setValue",'');
    SysUserStateChangeDatagrid.toolbar.find("#crtType").combobox("setValue",'');
    SysUserStateChangeDatagrid.toolbar.find("#isCurrent").combobox("setValue",'');
	SysUserStateChangeDatagrid.grid.datagrid("load", {});
});
